Skip to content

boot-utils: Fixes for flake8 and pylint#80

Merged
nathanchance merged 10 commits into
ClangBuiltLinux:mainfrom
nathanchance:linting-fixes
Dec 7, 2022
Merged

boot-utils: Fixes for flake8 and pylint#80
nathanchance merged 10 commits into
ClangBuiltLinux:mainfrom
nathanchance:linting-fixes

Conversation

@nathanchance

Copy link
Copy Markdown
Member

See the individual commits for the warnings.

Depends on ClangBuiltLinux/actions-workflows#4.

Due to what appears to be a yapf bug.

  boot-qemu.py:60:14: E251 unexpected spaces around keyword / parameter equals
  boot-qemu.py:68:14: E251 unexpected spaces around keyword / parameter equals
  boot-qemu.py:74:14: E251 unexpected spaces around keyword / parameter equals
  boot-qemu.py:81:14: E251 unexpected spaces around keyword / parameter equals
  boot-uml.py:25:14: E251 unexpected spaces around keyword / parameter equals
  boot-uml.py:33:14: E251 unexpected spaces around keyword / parameter equals

Link: google/yapf#393
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As recommended by pylint:

  boot-qemu.py:698:12: R1722: Consider using sys.exit() (consider-using-sys-exit)
  utils.py:29:4: R1722: Consider using sys.exit() (consider-using-sys-exit)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Cleans up the following pylint warnings:

  utils.py:55:11: R1714: Consider merging these comparisons with 'in' by using 'image in ('vmlinux', 'linux')'. Use a set instead if elements are hashable. (consider-using-in)
  boot-qemu.py:124:19: R1714: Consider merging these comparisons with 'in' by using 'guest_arch in ('arm', 'arm32_v7')'. Use a set instead if elements are hashable. (consider-using-in)
  boot-qemu.py:404:9: R1714: Consider merging these comparisons with 'in' by using 'arch in ('arm', 'arm32_v7')'. Use a set instead if elements are hashable. (consider-using-in)
  boot-qemu.py:414:9: R1714: Consider merging these comparisons with 'in' by using 'arch in ('arm64', 'arm64be')'. Use a set instead if elements are hashable. (consider-using-in)
  boot-qemu.py:456:9: R1714: Consider merging these comparisons with 'in' by using 'arch in ('mips', 'mipsel')'. Use a set instead if elements are hashable. (consider-using-in)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Helps compact code and eliminate the following pylint warnings:

  boot-qemu.py:132:21: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
  boot-qemu.py:132:46: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Elminate the following pylint warnings:

  boot-qemu.py:190:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
  boot-qemu.py:190:34: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As suggested by pylint:

  boot-qemu.py:666:27: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)

This allows us to drop the explicit call to wait(), as the exit path for
Popen() as a context manager automatically calls wait().

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
An explicit check parameter is recommended to make it obvious what the
error handling is. Cleans up the following pylint warnings:

  boot-qemu.py:127:39: W1510: Using subprocess.run without explicitly set `check` is not recommended. (subprocess-run-check)
  boot-qemu.py:659:19: W1510: Using subprocess.run without explicitly set `check` is not recommended. (subprocess-run-check)
  boot-qemu.py:672:16: W1510: Using subprocess.run without explicitly set `check` is not recommended. (subprocess-run-check)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
As recommended by pylint:

  boot-uml.py:47:4: W0621: Redefining name 'rootfs' from outer scope (line 80) (redefined-outer-name)
  boot-uml.py:60:15: W0621: Redefining name 'kernel' from outer scope (line 79) (redefined-outer-name)
  boot-uml.py:60:23: W0621: Redefining name 'rootfs' from outer scope (line 80) (redefined-outer-name)
  boot-qemu.py:141:18: W0621: Redefining name 'args' from outer scope (line 703) (redefined-outer-name)
  boot-qemu.py:202:14: W0621: Redefining name 'args' from outer scope (line 703) (redefined-outer-name)
  boot-qemu.py:322:26: W0621: Redefining name 'cfg' from outer scope (line 706) (redefined-outer-name)
  boot-qemu.py:356:18: W0621: Redefining name 'cfg' from outer scope (line 706) (redefined-outer-name)
  boot-qemu.py:632:16: W0621: Redefining name 'cfg' from outer scope (line 706) (redefined-outer-name)

As it turns out, this caught a bug in can_use_kvm(), where args was
being used without being passed into the function.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
These are scripts, not modules.

  boot-uml.py:1:0: C0103: Module name "boot-uml" doesn't conform to snake_case naming style (invalid-name)
  boot-qemu.py:1:0: C0103: Module name "boot-qemu" doesn't conform to snake_case naming style (invalid-name)

Signed-off-by: Nathan Chancellor <nathan@kernel.org>

@nickdesaulniers nickdesaulniers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; minor questions about the behavior wrt. failure to launch gdb, but I suspect if we quit out of gdb, that might interfere with any Check.

Comment thread boot-qemu.py
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance nathanchance merged commit 3edfe3a into ClangBuiltLinux:main Dec 7, 2022
@nathanchance nathanchance deleted the linting-fixes branch December 7, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants